<?php

define('_JEXEC', '1');
define('LPATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
ob_start();
require_once 'mvc/protected/config.php';

function my_autoloader($class_name) {

    if (class_exists($class_name, FALSE)) {
        return true;
    }

    if (file_exists(LIBS . $class_name . '.php')) {
        require_once LIBS . $class_name . '.php';
        return true;
    }

    if (file_exists(MODELS . $class_name . '.php')) {
        require_once MODELS . $class_name . '.php';
        return true;
    }

    if (file_exists(CONTROLLERS . $class_name . '.php')) {
        require_once CONTROLLERS . $class_name . '.php';
        return true;
    }

    if (file_exists(VIEWS . $class_name . '.php')) {
        require_once VIEWS . $class_name . '.php';
        return true;
    }

    return false;
}

//throw new Exception($message, $code, $previous);
if (!spl_autoload_register('my_autoloader')) {
    throw new Exception('Error::Could not set Autoload function ');
}

$app = new Bootstrap();
